<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    // 手写数组去重
    // var arr = [1, 22, 3, 22]
    // var newArr = []
    // var flag
    // for (var i = 0; i < arr.length; i++) {
    //   flag = true
    //   for (var j = i + 1; j < arr.length; j++) {
    //     if (arr[i] === arr[j]) flag = false
    //   }
    //   if (flag) newArr.push(arr[i])
    // }
    // console.log(newArr);


    // reduce
    // var arr = 





    console.log('1');
    setTimeout(function () {
      console.log('2');
      process.nextTick(function () {
        console.log('3');
      })
      new Promise(function (resolve) {
        console.log('4');
        resolve();
      }).then(function () {
        console.log('5')
      })
    })
    process.nextTick(function () {
      console.log('6');
    })
    new Promise(function (resolve) {
      console.log('7');
      resolve();
    }).then(function () {
      console.log('8')
    })
    setTimeout(function () {
      console.log('9');
      process.nextTick(function () {
        console.log('10');
      })
      new Promise(function (resolve) {
        console.log('11');
        resolve();
      }).then(function () {
        console.log('12')
      })
    })

    



  </script>
</body>

</html>